package com.ims.core.inconfig.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ims.common.annotation.Log;
import com.ims.common.core.controller.BaseController;
import com.ims.common.core.domain.AjaxResult;
import com.ims.common.enums.BusinessType;
import com.ims.core.inconfig.domain.TInBussiness;
import com.ims.core.inconfig.service.ITInBussinessService;
import com.ims.common.utils.poi.ExcelUtil;
import com.ims.common.core.page.TableDataInfo;

/**
 * 业务方管理Controller
 *
 * @author IMS
 * @date 2024-05-21
 */
@RestController
@RequestMapping("/inconfig/inbussiness")
public class TInBussinessController extends BaseController
{
    @Autowired
    private ITInBussinessService tInBussinessService;

    /**
     * 查询业务方管理列表
     */
    @PreAuthorize("@ss.hasPermi('inconfig:inbussiness:list')")
    @GetMapping("/list")
    public TableDataInfo list(TInBussiness tInBussiness)
    {
        startPage();
        List<TInBussiness> list = tInBussinessService.selectTInBussinessList(tInBussiness);
        return getDataTable(list);
    }

    /**
     * 导出业务方管理列表
     */
    @PreAuthorize("@ss.hasPermi('inconfig:inbussiness:export')")
    @Log(title = "业务方管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TInBussiness tInBussiness)
    {
        List<TInBussiness> list = tInBussinessService.selectTInBussinessList(tInBussiness);
        ExcelUtil<TInBussiness> util = new ExcelUtil<TInBussiness>(TInBussiness.class);
        util.exportExcel(response, list, "业务方管理数据");
    }

    /**
     * 获取业务方管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('inconfig:inbussiness:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tInBussinessService.selectTInBussinessById(id));
    }

    /**
     * 新增业务方管理
     */
    @PreAuthorize("@ss.hasPermi('inconfig:inbussiness:add')")
    @Log(title = "业务方管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TInBussiness tInBussiness)
    {
        return toAjax(tInBussinessService.insertTInBussiness(tInBussiness));
    }

    /**
     * 修改业务方管理
     */
    @PreAuthorize("@ss.hasPermi('inconfig:inbussiness:edit')")
    @Log(title = "业务方管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TInBussiness tInBussiness)
    {
        return toAjax(tInBussinessService.updateTInBussiness(tInBussiness));
    }

    /**
     * 删除业务方管理
     */
    @PreAuthorize("@ss.hasPermi('inconfig:inbussiness:remove')")
    @Log(title = "业务方管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tInBussinessService.deleteTInBussinessByIds(ids));
    }
}
